define(function(require, exports, module){
	var cloudprocurementTemp = require("text!../template/cloudprocurement.html");
	//var Scroll = require("scroll");
	
	module.exports = Nuui.View.extend({

		template:cloudprocurementTemp,

		onRender:function(){
			var view=this;
		
		},

		onShow:function(){            
			var view = this;
			//var target=App.storage.get('productCode');
			var targetName=App.storage.get('productName');
			//target="product/"+target;
			//App.request(target,{
			App.request(App.server.getServePath(App.path.productAction),{
				success:function(data){
					if(data.ec){
						alert(data.em);

					}else{
						//全部产品在一个json文件
						var res=data.productList;
						for(var i in res){
							var tags=res[i].productClassification;
							var random=Math.floor(Math.random()*(tags.length));
							if(targetName=="全部"){
								while(tags[random]=="爆款"){
									random=Math.floor(Math.random()*(tags.length));
								}
								foo(i,res,tags[random])
							}else{
								for(var j=0;j<tags.length;j++){
									if(targetName==tags[j]){
										foo(i,res,targetName)
									}
								}
							}
							
						}
						$(".header_title").text(targetName);
						function foo(i,res,cate){
							var html='';
							html+='<dl  data-code="'+i+'">';
							html+='	<dt><img src="images/img/'+res[i].listImg+'"/></dt>';
							html+='	<dd>'+res[i].name_CN+'</dd>';
							html+='	<div>';
							html+='		<div  class="cloud-pl" >';
							html+='			<div>';
							html+='				<span >成交<em style="color:#fe0000;">'+res[i].sales+'</em>笔</span>';
							html+='				<span href="##" style="color:#fe0000;">'+res[i].price+'<em style="color:#999;">元</em></span>';
							html+='			</div>';
//							html+='			<div  class="intro">'+res[i].introduce.detailedIntroduction+'</div>';
										
				
							html+='		</div>';
							html+='		<div class="cloud-pr" >';
							if(res[i].isHot==1){
								html+='			<span><img src="../../../images/img/bao.png" alt="" style="display: inline-block;width:.4rem ;height: .37rem;"/></span>';
							}else{
								html+='			<span></span>';
							}
							
										
							html+='			<span class="cate">'+cate+'</span>';
							html+='		</div>';
							html+='	</div>';
							html+='</dl>';
			
							view.$(".cloud-section").append(html);
						}
						
					}
				}
			})
			view.$('.cloud-section').on('tap','dl',function(){
				var targetCode=$(this).attr('data-code');
 				App.storage.set('yunCode',targetCode);
 				App.navigate("example/index/MDM",true);
        		return false;
			})



		}
	});
});